<?php
namespace Plu\Library\Services\Redis\Tag;

use Plu\Library\Services\ServiceBase;

class TagRedis extends ServiceBase {
    const key_of_tags_member = "tag:%d:member";

    public function validation($tags, $itemType) {
        $redis = $this->getRedis('vector');

        $key = sprintf(self::key_of_tags_member, $itemType);

        $items = array();
        for ($i = 0, $len = count($tags); $i < $len; $i ++) {
            $t = $tags[$i];
            if ($redis->sContains($key, $t)) {
                $items[] = $t;
            }
        }

        return $items;
    }

    public function getHotVideoCategory(){
        $redis = $this->getRedis('cache');
        $hash_key = "media:hotcategory";
        $data = $redis->hGet($hash_key,'hotVideoCategory');
        return $data;
    }
}
?>
